import 'package:flutter_base/common/utils/utils.dart';
import 'package:flutter_base/common/values/colors.dart';
import 'package:flutter_base/common/values/values.dart';
import 'package:flutter/material.dart';


/// 扁平圆角按钮
Widget btnFlatButtonWidget({
   VoidCallback? onPressed,
  double width = 140,
  double height = 44,
  Color gbColor = AppColors.primaryElement,
  String title = "button",
  Color fontColor = AppColors.primaryElementText,
  double fontSize = 18,
  String fontName = "Montserrat",
  FontWeight fontWeight = FontWeight.w400,
}) {
  return Container(
    width: zhiSetWidth(width),
    height: zhiSetHeight(height),
    child: FlatButton(
      onPressed: isEmpty(onPressed)?(){}:onPressed,
      color: isEmpty(onPressed)?Colors.blue[200]:gbColor,
      shape: RoundedRectangleBorder(
        borderRadius: Radii.k6pxRadius,
      ),
      child: Text(
        title,
        textAlign: TextAlign.center,
        style: TextStyle(
          color: fontColor,
          fontFamily: fontName,
          fontWeight: fontWeight,
          fontSize: zhiSetFontSize(fontSize),
          height: 1,
        ),
      ),
    ),
  );
}

/// 第三方按钮
Widget btnFlatButtonBorderOnlyWidget({
  required VoidCallback onPressed,
  double width = 88,
  double height = 44,
  String? iconFileName,
}) {
  return Container(
    width: zhiSetWidth(width),
    height: zhiSetHeight(height),
    child: FlatButton(
      onPressed: onPressed,
      shape: RoundedRectangleBorder(
        side: Borders.primaryBorder,
        borderRadius: Radii.k6pxRadius,
      ),
      child: Image.asset(
        "assets/images/icons-$iconFileName.png",
      ),
    ),
  );
}

class NextButton extends StatelessWidget {
  const NextButton({Key? key, this.title, this.onPressed, this.margin})
      : super(key: key);
  final title;
  final VoidCallback? onPressed;
  final EdgeInsets? margin;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onPressed,
      child: Container(
        padding: EdgeInsets.symmetric(vertical: zhiSetHeight(8)),
        decoration: new BoxDecoration(
          //背景
            color: AppColors.primaryElement,
            //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
            borderRadius: BorderRadius.circular(44 / 2)),
        child: Center(
          child: Text(
            title,
            style: Theme.of(context)
                .textTheme
                .button!
                .copyWith(color: Colors.white),
          ),
        ),
      ),
    );
  }
}